<template>
  <el-dialog
    class="guard_dialog"
    :model-value="modelValue"
    title="守护榜"
    style="width: 324px; height: auto !important"
    draggable
    :modal="false"
    :append-to-body="true"
    show
    @update:model-value="handleClose"
  >
    <template #header="{ close, titleId, titleClass }">
      <div class="custom_header">
        <span>守护榜</span>
      </div>
    </template>
    <div class="flex_out">
      <el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick">
        <el-tab-pane label="守护周期榜" name="first"></el-tab-pane>
        <el-tab-pane label="守护总榜" name="second"></el-tab-pane>
      </el-tabs>
      <div class="nameplate_div">
        <span class="nameplate_label">守护铭牌：</span>
        <span class="nameplate_value">灌汤包</span>
        <el-button type="text" @click="updateGardianNameplateRef.show()">编辑</el-button>
      </div>
      <div class="period_div">
        <el-radio-group v-model="period" size="small">
          <el-radio-button label="日" />
          <el-radio-button label="周" />
          <el-radio-button label="月" />
        </el-radio-group>
      </div>
      <el-scrollbar height="600px" style="width: 100%; margin: 10px 0 10px 0">
        <ul class="infinite-list">
          <li v-for="i in count" :key="i" class="infinite-list-item">
            <div class="li_item">
              <!-- {{ i }} -->
              <div
                style="
                  display: flex;
                  flex-direction: row;
                  justify-content: center;
                  align-items: center;
                "
              >
                <img v-if="i == 1" src="@/assets/live/king1.png" alt="" class="king_img" />
                <img v-else-if="i == 2" src="@/assets/live/king2.png" alt="" class="king_img" />
                <img v-else-if="i == 3" src="@/assets/live/king3.png" alt="" class="king_img" />
                <span v-else class="other_rank">{{ i }}</span>
                <img
                  style="margin-left: 8px"
                  src="https://axure-file.lanhuapp.com/md5__862eb7a7eeb6b7490153498e634cb182.jpg"
                  alt=""
                  srcset=""
                />
                <div
                  style="
                    display: flex;
                    flex-direction: column;
                    margin-left: 8px;
                    align-items: flex-start;
                  "
                >
                  <span class="name_span">用户昵称</span>
                  <div>
                    <span class="id_span">ID</span>
                    <span class="id_span">132489489456</span>
                  </div>
                </div>
              </div>
              <div>
                <div style="display: flex">
                  <span class="guard_count">8454</span>
                  <img src="@/assets/live/crystal.png" style="width: 23px; height: 16px" alt="" />
                </div>
                <span class="crystal_label">水晶星数</span>
              </div>
            </div>
          </li>
        </ul>
      </el-scrollbar>
    </div>

    <!-- <template #footer>
      <el-button @click="handleClose">关闭</el-button>
    </template> -->
  </el-dialog>
  <UpdateGardianNameplate ref="updateGardianNameplateRef" />
</template>

<script setup>
import { defineProps, defineEmits } from "vue";
import UpdateGardianNameplate from "../UpdateGardianNameplate.vue";

defineProps({
  modelValue: {
    // 接收父组件v-model传值
    type: Boolean,
    default: false,
  },
});
const activeName = ref("first");
const count = ref(10);
const updateGardianNameplateRef = ref();
const emit = defineEmits(["update:modelValue"]);
const period = ref("日");
// 关闭对话框时通知父组件更新状态
const handleClose = () => {
  emit("update:modelValue", false);
};
</script>
<style lang="scss">
.guard_dialog {
  padding: 0;
  background-color: #222222;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 8px;

  .el-tabs {
    color: #fff;

    .el-tabs__item {
      color: #fff;
    }

    .el-tabs__nav-wrap:after {
      background-color: #222;
    }

    .el-tabs__active-bar {
      background-color: #fff;
      left: calc(31% - 32px) !important;
      width: 25px !important;
    }
  }

  .custom_header {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-content: center;
    justify-content: flex-start;
    align-items: center;
    color: #fff;
    line-height: 15px;
  }

  .el-dialog__header {
    border: 1px solid rgba(216, 216, 216, 0.5);
    padding: 20px 20px 10px 20px;
    height: 56px;

    .el-dialog__headerbtn {
      height: 56px;
    }
  }

  .search_div {
    width: 100%;

    .el-input__wrapper {
      width: 177px;
      height: 26px;
      border-radius: 166px 166px 166px 166px;
      border: 1px solid #ffffff;
      background: #222;
      color: #fff;
    }
  }

  .nameplate_div {
    width: calc(100% - 12px);
    margin: 0 auto;
    padding-left: 8px;
    height: 30px;
    line-height: 30px;
    background: #e2f1ff;
    border-radius: 2px 2px 2px 2px;

    .nameplate_label {
      width: 70px;
      height: 22px;
      font-weight: 400;
      font-size: 14px;
      color: #4e5969;
      text-align: left;
      font-style: normal;
      text-transform: none;
    }

    .nameplate_value {
      width: 42px;
      height: 22px;
      font-weight: 400;
      font-size: 14px;
      color: #1d2129;
      text-align: left;
      font-style: normal;
      text-transform: none;
    }

    .el-button span {
      color: #165dff;
    }
  }

  .period_div {
    width: 100%;
    margin-top: 7px;

    .el-radio-group {
      float: right;
      margin-right: 6px;

      .el-radio-button.is-active
        .el-radio-button__original-radio:not(:disabled)
        + .el-radio-button__inner {
        background-color: #a09aee;
        border-color: #a09aee;
        box-shadow: none;
      }
    }
  }

  .el-button {
    width: 68px;
    height: 22px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px 4px 4px 4px;

    span {
      font-weight: 400;
      font-size: 12px;
      color: #ff4e6c;
      line-height: 22px;
      text-align: left;
      font-style: normal;
      text-transform: none;
    }
  }

  .flex_out {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    align-content: center;
    align-items: center;
    margin-top: 6px;
  }

  .flex_inner {
    width: 100%;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-content: center;
    justify-content: space-around;
    align-items: center;
  }

  .flex_date {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-weight: 400;
    font-size: 14px;
    line-height: 24px;
    text-align: center;
    font-style: normal;
    text-transform: none;
  }

  .infinite-list {
    height: 600px;
    width: 100%;
    padding: 0;
    margin: 0;
    list-style: none;
  }

  .infinite-list .infinite-list-item {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 50px;
    margin: 30px 10px;

    .king_img {
      width: 32px;
      height: 23px;
    }

    .other_rank {
      display: inline-block;
      width: 32px;
      height: 23px;
      height: 14px;
      font-weight: 400;
      font-size: 14px;
      color: rgba(255, 255, 255, 0.85);
      line-height: 14px;
      text-align: center;
      font-style: normal;
      text-transform: none;
    }
  }

  .infinite-list .infinite-list-item + .list-item {
    margin-top: 10px;
    margin: 10px 6px;
  }

  .li_item {
    display: flex;
    align-items: stretch;
    justify-content: space-between !important;
    height: 3.125rem;
    /* background: var(--el-color-primary-light-9); */
    margin: 10px 0 10px 0 !important;
    align-content: center;
    align-items: center;
    flex-wrap: nowrap;
    flex-direction: row;
    width: 100%;

    img {
      width: 48px;
      height: 48px;
      border-radius: 50%;
    }

    .name_span {
      height: 17px;
      font-weight: 400;
      font-size: 14px;
      color: #ffffff;
      line-height: 16px;
      text-align: center;
      font-style: normal;
      text-transform: none;
    }

    .id_span {
      height: 17px;
      font-weight: 400;
      font-size: 12px;
      color: #ffffff;
      line-height: 16px;
      text-align: center;
      font-style: normal;
      text-transform: none;
    }

    .guard_count {
      height: 17px;
      font-weight: 700;
      font-size: 16px;
      color: #ffffff;
      line-height: 16px;
      text-align: center;
      font-style: normal;
      text-transform: none;
    }

    .crystal_label {
      height: 16px;
      font-weight: 400;
      font-size: 10px;
      color: #979797;
      line-height: 16px;
      text-align: center;
      font-style: normal;
      text-transform: none;
      margin-left: 5px;
    }
  }

  .el-dialog__footer {
    padding: 10px;
  }
}
</style>
